﻿using System.Data.SqlClient;
using ECG.Common;

namespace ECG.DAL
{
    public partial class UserDb
    {
        public static UserDto GetAdminByUserName(string username)
        {
            var dao = SharedSqlDao;
            var commad = dao.GetDbSprocCommand("WSPX_User_SelectByUserName");
            try
            {
                commad.Parameters.Add(dao.CreateParameter("@UserName", username));
                var result = dao.GetSingleDTO<UserDto>(ref commad);
                return result;
            }
            finally
            {
                commad.Connection.Close();
            }
        }

        public static UserDto GetByUserName(string userName)
        {
            var dao = SharedSqlDao;
            SqlCommand command = dao.GetDbSprocCommand("WSPX_Users_GetByUserName");
            try
            {
                command.Parameters.Add(dao.CreateParameter("@UserName", userName));
                return dao.GetSingleDTO<UserDto>(ref command);
            }
            finally
            {
                command.Connection.Close();
            }
        }//End method
    }
}
